package services;

import dao.ChannelDAO;
import entities.Channel;

import javax.ejb.EJB;
import javax.ejb.Local;
import javax.ejb.Stateless;
import java.util.List;

/**
 * Service for work with channels
 * User: kaiser
 * Date: 7/31/13
 * Time: 9:16 PM
 */
@Stateless
@Local
public class ChannelService {

    @EJB
    ChannelDAO channelDAO;

    /**
     * Get list of all channels stored in Db
     *
     * @return list of channels
     */
    public List<Channel> getAllChannels() {
        return channelDAO.getAll();
    }

    /**
     * Check is channel with some primary name exist in db
     *
     * @param id
     * @return true if exist
     */
    public boolean isChannelExist(String id) {
        return channelDAO.isExist(id);
    }

    /**
     * Getting channel entity by name
     *
     * @param name channel primary name
     * @return Channel entity is exist? null if not exist
     */
    public Channel getByName(String name) {
        return channelDAO.getByName(name);
    }
}
